package org.liuh.t2020.netty.httpserver01;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @Description TODO 服务初始化器.
 * @Author liuh
 */
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {


    /**
     * @Description TODO 初始化，一个回调的方法..
     * @Author liuh
     * @Date 2020/1/12
     * @Params * @param null
     */
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        // 1. 获取pipeline
        ChannelPipeline pipeline = ch.pipeline();
        // 2.设置处理器！ , httpServerCodec 是一个很重要的处理器.
        pipeline.addLast("httpServerCodec", new HttpServerCodec());
        // 3. 添加自己定义的处理器.
        pipeline.addLast("testHandle", new TestHttpServerHandle());

    }
}
